package prv.behavioral.chainOfResponsibility;

public class Demo {
	public static void main(String[] args) {
		// Build the chain of responsibility
		Logger logger, logger1, logger2;
		logger = new StdoutLogger(Logger.DEBUG);
		logger.setNext(new EmailLogger(Logger.NOTICE)).setNext(new StderrLogger(Logger.ERR));
//		logger = new StdoutLogger(Logger.DEBUG);
//		logger1 = logger.setNext(new EmailLogger(Logger.NOTICE));
//		logger2 = logger1.setNext(new StderrLogger(Logger.ERR));

		// Handled by StdoutLogger
		logger.message("Entering function y.", Logger.DEBUG);

		// Handled by StdoutLogger and EmailLogger
		logger.message("Step1 completed.", Logger.NOTICE);

		// Handled by all three loggers
		logger.message("An error has occurred.", Logger.ERR);
	}
}
